import Text from './Text.od'
import Link from './Link.od'
import Paragraph from './Paragraph.od'
import Headline from './Headline.od'
import List from './List.od'
import Table from './Table.od'
import Div from './Div.od'
import Form from './Form.od'
import Audio from './Audio.od'
import Video from './Video.od'
import Image from './Image.od'
import Input from './Input.od'
import Radio from './Radio.od'
import Checkbox from './Checkbox.od'
import Select from './Select.od'
import Textarea from './Textarea.od'
import Button from './Button.od'
import Uploader from './Uploader.od'
import Icon from './Icon.od'
import DataSource from './DataSource.od'
import DataList from './DataList.od'
import MButton from '../mui/MButton.od'
import MBadge from '../mui/MBadge.od'
import MCheck from '../mui/MCheck.od'
import MCheckBox from '../mui/MCheckBox.od'
import MDatePicker from '../mui/MDatePicker.od'
import MInput from '../mui/MInput.od'
import MNumber from '../mui/MNumber.od'
import MPassword from '../mui/MPassword.od'
import MRadio from '../mui/MRadio.od'
import MSearch from '../mui/MSearch.od'
import MTimePicker from '../mui/MTimePicker.od'
import MPicker from '../mui/MPicker.od'
import MProgress from '../mui/MProgress.od'
import MRange from '../mui/MRange.od'
import MAccordion from '../mui/MAccordion.od'
import MCardView from '../mui/MCardView.od'
import MGallery from '../mui/MGallery.od'
import MList from '../mui/MList.od'
import MTexture from '../mui/MTexture.od'
import MTextureTable from '../mui/MTexture.od'
import MBarcode from '../mui/MBarcode.od'
import MQRCode from '../mui/MQRCode.od'
import MGrid from '../mui/MGrid.od'
import MAside from '../mui/MAside.od'
import MBottomBar from '../mui/MBottomBar.od'
import MSwitch from '../mui/MSwitch.od'
import MColumn from '../mui/MColumn.od'
import MPagination from '../mui/MPagination.od'
import MHeader from '../mui/MHeader.od'
export default class OdManager{
    constructor(){

    }
    injectProject(project){
        this.project = project
    }
    loadOd(){
        $('[action-view]').each((index, item) => {
            let $this = $(item)
            let view = $this.attr('action-view')
            let div = $('<div></div>')
            div.attr('class', 'od-view')
            //div.css('display', OdManager.ods[view].type?OdManager.ods[view].type:'block')
            console.log(view)
            div.html(OdManager.ods[view].template)
            $this.append(div)
            $this.append('<i class = "drag fa fa-arrows"></i>')
        })

        //初始化可拖拽
        $('.sortable').sortable({
            connectWith: '.sortable',
            handle:'.drag',
            revert:true,
            update: function(e, t) {
                let $this = $(t.item[0])
                let view = $this.attr('action-view')
                let od = OdManager.ods[view]
                $this.css('display',od.type?od.type:'block')
                $this.children('.preview').remove()
                $this.children('.od-view').css('display',od.type?od.type:'block')

            }
        })
        $('.view-table .od-box').draggable({
            connectToSortable: '.sortable',
            helper: 'clone',
            hanle: '.drag',
            drag:(e,t) => {
             //   console.log(e)
             //   console.log(t)
            }

        })
    }
}
OdManager.ods = {
    'text' : Text,
    'link' : Link,
    'paragraph' : Paragraph,
    'headline' : Headline,
    'list' : List,
    'table' : Table,
    'div'   : Div,
    'form' : Form,
    'audio' : Audio,
    'video' : Video,
    'image' : Image,
    'input' : Input,
    'radio' : Radio,
    'checkbox' : Checkbox,
    'select' : Select,
    'textarea' : Textarea,
    'button' : Button,
    'uploader' : Uploader,
    'icon' : Icon,
    'datasource' : DataSource,
    'datalist' : DataList,
    'mbutton' : MButton,
    'mbadge' : MBadge,
    'mcheck' : MCheck,
    'mcheckbox' : MCheckBox,
    'mdatepicker' : MDatePicker,
    'minput' : MInput,
    'mnumber' : MNumber,
    'mpassword' : MPassword,
    'mradio' : MRadio,
    'msearch' : MSearch,
    'mtimepicker' : MTimePicker,
    'mpicker' : MPicker,
    'mprogress' : MProgress,
    'mrange' : MRange,
    'maccordion' : MAccordion,
    'mcardview' : MCardView,
    'mgallery' : MGallery,
    'mlist' : MList,
    'mtexture' : MTexture,
    'mtexturetable' : MTextureTable,
    'mbarcode' : MBarcode,
    'mqrcode' : MQRCode,
    'mgrid' : MGrid,
    'maside' : MAside,
    'mbottombar' : MBottomBar,
    'mswitch' : MSwitch,
    'mcolumn' : MColumn,
    'mpagination' : MPagination,
    'mheader' : MHeader
}
console.log(OdManager.ods)